using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using System.Data;
using XBLib.Dal.AdoDal;
using DataInfo;
using KenLib.Common;
namespace KenLib.Dal
{
    public class 健康診断情報Dao : BaseAdoDao
      {
          private string m_requestTime;
          private string m_displayTime;
          public int Insert(健康診断情報 obj)
          {
              int i = 0;
              try
              {
                  m_requestTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  DbParameter param20 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
                  DbParameter param1 = _daoHelper.CreateParameter("@健康診断日", obj.健康診断日, DbType.DateTime);
                  DbParameter param2 = _daoHelper.CreateParameter("@健康状態", obj.健康状態, DbType.String);
                  DbParameter param3 = _daoHelper.CreateParameter("@精密検査日", obj.精密検査日, DbType.DateTime);
                  DbParameter param4 = _daoHelper.CreateParameter("@経過観察項目", obj.経過観察項目, DbType.String);
                  DbParameter param5 = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);
                  DbCommand command = _daoHelper.CreateCommand(CommandNameManager.Insert_HumanPhysicalExamInfo, CommandType.StoredProcedure,param20, param1, param2, param3, param4, param5);
                  i = _daoHelper.Execute(command);
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteLog("", "", "INSERT", "Insert_HumanPhysicalExamInfo", m_requestTime, m_displayTime);
              }
              catch (Exception ex)
              {
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteErr("", "", "SELECT", ex.Message, m_requestTime, m_displayTime);
              }
              return i;
          }

          public int Update(健康診断情報 obj)
          {
              int i = 0;
              try
              {
                  m_requestTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  DbParameter param20 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
                  DbParameter param0 = _daoHelper.CreateParameter("@ID", obj.ID, DbType.Int32);
                  DbParameter param1 = _daoHelper.CreateParameter("@健康診断日", obj.健康診断日, DbType.DateTime);
                  DbParameter param2 = _daoHelper.CreateParameter("@健康状態", obj.健康状態, DbType.String);
                  DbParameter param3 = _daoHelper.CreateParameter("@精密検査日", obj.精密検査日, DbType.DateTime);
                  DbParameter param4 = _daoHelper.CreateParameter("@経過観察項目", obj.経過観察項目, DbType.String);
                  DbParameter param5 = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);
                  DbCommand command = _daoHelper.CreateCommand(CommandNameManager.Update_HumanPhysicalExamInfo, CommandType.StoredProcedure,param20, param0, param1, param2, param3, param4, param5);
                  i = _daoHelper.Execute(command);
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteLog("", "", "UPDATE", "Update_HumanPhysicalExamInfo", m_requestTime, m_displayTime);
              }
              catch (Exception ex)
              {
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteErr("", "", "SELECT", ex.Message, m_requestTime, m_displayTime);
              }
              return i;
          }

          public int Delete(int id)
          {
              int i = 0;
              try
              {
                  m_requestTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  DbParameter param0 = _daoHelper.CreateParameter("@ID", id, DbType.Int32);

                  DbCommand command = _daoHelper.CreateCommand(CommandNameManager.Delete_HumanPhysicalExamInfo, CommandType.StoredProcedure, param0);
                  i = _daoHelper.Execute(command);
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteLog("", "", "DELETE", "Delete_HumanPhysicalExamInfo", m_requestTime, m_displayTime);
              }
              catch (Exception ex)
              {
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteErr("", "", "SELECT", ex.Message, m_requestTime, m_displayTime);
              }
              return i;
          }
          #region
          public DataTable getGrv_健康診断(int 社員ID)
          {
              DbParameter dbParam1 = _daoHelper.CreateParameter("@社員ID", 社員ID, DbType.Int32);
              DbCommand dbcommand = _daoHelper.CreateCommand("sp_getGrv_健康診断_TUNG", CommandType.StoredProcedure, dbParam1);
              return _daoHelper.Query(dbcommand);
          }
          #endregion
          #region Hunglt
          public void UpdateInfo健康診断情報(健康診断情報 obj)
          {
              DbParameter param廃止区分 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int32);
              DbParameter param健康診断日 = _daoHelper.CreateParameter("@健康診断日", obj.健康診断日, DbType.DateTime);
              DbParameter param健康状態 = _daoHelper.CreateParameter("@健康状態", obj.健康状態, DbType.String);
              DbParameter param精密検査日 = _daoHelper.CreateParameter("@精密検査日", obj.精密検査日, DbType.DateTime);
              DbParameter param経過観察項目 = _daoHelper.CreateParameter("@経過観察項目", obj.経過観察項目, DbType.String);
              DbParameter param社員ID = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);

              DbCommand dbcommand = _daoHelper.CreateCommand("sp_update_健康診断情報_FormJ_Hunglt", CommandType.StoredProcedure,
                 param廃止区分, param健康診断日, param健康状態, param精密検査日, param経過観察項目, param社員ID);
              _daoHelper.Execute(dbcommand);
          }
          #endregion
      }
}
